import type { PageParams } from '@/api/model/pageParams';
import { request } from '@/utils/request';

const page = async (params: PageParams) => {
    return request.post({
        url: '/sysRole/page',
        data: params,
    });
};

const insertApi = async (data: any) => {
    return request.post({
        url: '/sysRole/insert',
        data,
    });
};

const updateApi = async (data: any) => {
    return request.post({
        url: '/sysRole/update',
        data,
    });
};

const deleteById = async (id: string) => {
    return request.get({
        url: `/sysRole/delete/${id}`,
    });
};

const getOptions = async () => {
    return request.get({
        url: `/sysRole/roleOptions`,
    });
};

const getPermissions = async (roleId: string) => {
    return request.get({
        url: `/sysRole/getPermissions/${roleId}`,
    });
};

const roleCheck = async (params: { roleId: string; check: boolean; permissionIds: string[] }) => {
    return request.post({
        url: `/sysRole/check`,
        data: params,
    });
};

export { deleteById, getOptions, getPermissions, insertApi, page, roleCheck, updateApi };
